<template>
{{#if ctrl.psSysPFPlugin}}
    {{> @macro/plugins/widget/widget-use.hbs appPlugin=ctrl.psSysPFPlugin}}
{{else}}
    <AppExpBar :class="classNames" :id="controlID">
        {{#if ctrl.showTitleBar}}
        <template #titleBar>
            <div class="control-header__left__caption">
            {{#if ctrl.psSysImage}}
            {{#if ctrl.psSysImage.imagePath}}
                <img src="{{ctrl.psSysImage.imagePath}}"/>
            {{/if}}
            {{#if ctrl.psSysImage.cssClass}}
                <i class="{{ctrl.psSysImage.cssClass}}"></i>
            {{/if}}
            {{/if}}
                <span class="text">\{{$t(model.lanResTag, model.title)}}</span>
            </div>
        </template>
        {{/if}}
        {{#if ctrl.enableSearch}}
        <template #quickSearch>
            {{> @macro/common/quick-search.hbs}}
        </template>
        {{/if}}
        {{#each ctrl.psControls as | ctrl |}}
        {{#eq ctrl.controlType 'TOOLBAR'}}
        <template #toolbar>
            {{> @macro/widgets/toolbar/toolbar.hbs ctrl=ctrl}}
        </template>
        {{/eq}}
        {{#eq ctrl.controlType "TREEVIEW"}}
        <template #default>
            {{> @macro/widgets/tree-detail/tree.hbs ctrl=ctrl props=":selectFirstDefault='true'"}}
        </template>
        {{/eq}}
        {{/each}}
    </AppExpBar>
{{/if}}
</template>
<script setup lang="ts">
// 基于template/src/widgets/\{{appEntities}}/\{{ctrls@TREEEXPBAR}}-tree-exp-bar/\{{spinalCase ctrl.codeName}}-tree-exp-bar.vue.hbs生成
{{> @macro/plugins/widget/widget-import.hbs ctrl=ctrl}}
{{#ctrl.psControls}}
    {{#eq controlType "TREEVIEW"}}
import {{codeName}}Tree from '@widgets/{{spinalCase appEntity.codeName}}/{{spinalCase codeName}}-tree/{{spinalCase codeName}}-tree.vue';
    {{/eq}}
    {{#eq controlType 'TOOLBAR'}}
import { AppToolbar } from '@components/widgets/toolbar';
    {{/eq}}
{{/ctrl.psControls}}
import { model } from './{{spinalCase ctrl.codeName}}-tree-exp-bar-model';
import { AppExpBar } from '@components/widgets/exp-bar';
import { TreeExpBarActionType, TreeExpBarController, IContext, ITreeExpBarAbility, ITreeExpBarControllerParams, ITreeExpBarStore, IParam, ITreeExpBarController, ILoadingHelper, createUUID, IViewCtx } from '@/core';
import {
{{#ctrl.ctrls}}
    {{#eq controlType 'TOOLBAR'}}
    handleToolbarItemClick,
    {{/eq}}
{{/ctrl.ctrls}}
{{#if ctrl.enableSearch}}
    handleQuickSearch,
{{/if}}
    useNavParamsBind,
    useEventBind,
    getCtrlClassNames,
    handleCtrlInit,
    handleCtrlAction,
    handleCtrlDestroy
} from '@/hooks/use-ctrl';
{{> @macro/widgets/ctrl/ctrl-props.hbs
    props="openView?: Function;
    newView?: Function;
    "
}}

{{> @macro/common/emit.hbs name="ctrl" actionType="TreeExpBarActionType" ability="ITreeExpBarAbility"}}

const controlID = 'id' + createUUID(); 

const classNames = computed(() => {
    const classNames = getCtrlClassNames(model, props);
    Object.assign(classNames, {
        'app-control-expbar': true
    })
    return classNames;
});

// 树导航控制器
const params: ITreeExpBarControllerParams<TreeExpBarActionType, ITreeExpBarAbility> = {
    name: props.name,
    model,
    evt,
    controlID,
    openView: props.openView,
    newView: props.newView,
    closeView: props.closeView,
    pViewCtx: props.pViewCtx,
    handler: (data: ITreeExpBarStore) => { return reactive(data); }
};

{{> @macro/common/controller.hbs name="ctrl" IController="ITreeExpBarController" store="ITreeExpBarStore" ability="ITreeExpBarAbility" controller="TreeExpBarController"}}

</script>